﻿@model ScmDailycheckViewModel
@{
    ViewBag.Title = "日常检查-列表";
    Layout = null;
}
<script type="text/javascript">
    $(document).ready(function () {
        $("#iput_ispro").val(@ViewBag.iput_ispro);
    });
</script>
<div class="page" style="border-top: 1px solid #b8d0d6;" layouth="1">
    @using (Html.BeginForm("SplitPage", "ScmDailyCheck", null, FormMethod.Post, new { id = "pagerForm", onsubmit = "return navTabSearch(this);" }))
    {
        <input type="hidden" name="pageNum" value="1" />
        <input type="hidden" name="numPerPage" value="@(ViewBag.numPerPage)" />
        <ul class="searchBar">
            <li><span>被检单位：</span>
                <input type="text" name="iput_bdname" value="@(ViewBag.iput_bdname)"/>
            </li>
            <li>
                <span>存在问题：</span>
                <select name="iput_ispro" id="iput_ispro">
                    <option value="-1">是否存在问题</option>
                    <option value="0">否</option>
                    <option value="1">是</option>
                </select>
            </li>
            <li><span>检查时间：</span>
                <input type="text" name="iput_timestart" value="@(ViewBag.iput_timestart)" class="date" />
                <span>-</span>
                <input type="text" name="iput_timeend" value="@(ViewBag.iput_timeend)" class="date" />
            </li>
            <li>
                <button type="submit" class="btn btn-success btn-xs">
                    搜索</button>
            </li>
        </ul>
    }
    <div class="panelBar" style="border-top: none;">
        <ul class="toolBar">
            <li>
                @Html.PermissionButton("SafetyConstruction.ScmDailyCheck.Create", "listAddId",
                    Url.Action("DailyCheckAdd", "ScmDailyCheck"),
                    "添加",
                    new Dictionary<string, object>
                    {
                        {"class","add"} ,{"mask","true"},{"rel","ctgl_jc_add"},{"target","dialog"},{"width","400"},{"height","400"}
                    })
            </li>
            <li>
                @Html.PermissionButton("SafetyConstruction.ScmDailyCheck.Delete", "listDeleteId",
                    Url.Action("DailyCheckDelete", "ScmDailyCheck", new { id = "{tr_id}" }),
                    "删除",
                    new Dictionary<string, object>
                    {
                        {"class","delete"} ,{"mask","true"},{"title","确定要删除该条记录吗?"},{"target","ajaxTodo"}
                    })
            </li>
            <li>
                @Html.PermissionButton("SafetyConstruction.ScmDailyCheck.Edit", "listEditId",
                    Url.Action("DailyCheckEdit", "ScmDailyCheck", new { id = "{tr_id}" }),
                    "修改",
                    new Dictionary<string, object>
                    {
                        {"class","edit"} ,{"mask","true"},{"rel","ctgl_jc_edit"},{"target","dialog"},{"width","400"},{"height","400"},{"warn","请选择一条信息"}
                    })
            </li>
            <li>
                @Html.PermissionButton("SafetyConstruction.ScmDailyCheck.Detail", "listDetailId",
                    Url.Action("DailyCheckDetail", "ScmDailyCheck", new { id = "{tr_id}" }),
                    "查看",
                    new Dictionary<string, object>
                    {
                        {"class","detail"} ,{"mask","true"},{"rel","ctgl_jc_edit"},{"target","dialog"},{"width","400"},{"height","400"},{"warn","请选择一条信息"}
                    })
            </li>
            <li class="line">line</li>
            <li>
                @Html.PermissionButton("SafetyConstruction.ScmDailyCheck.ExtendCorrectTerm", "listExtendCorrectTermId",
                    Url.Action("DailyCheckExtendCorrectTerm", "ScmDailyCheck", new { id = "{tr_id}" }),
                    "延长整改期限",
                    new Dictionary<string, object>
                    {
                        {"class","collect"} ,{"mask","true"},{"rel","ctgl_jc_edit"},{"target","dialog"},{"width","400"},{"height","320"},{"warn","请选择一条信息"}
                    })
            </li>
            <li>
                @Html.PermissionButton("SafetyConstruction.ScmDailyCheck.Approval", "listApprovalId",
                    Url.Action("DailyCheckApproval", "ScmDailyCheck", new { id = "{tr_id}" }),
                    "下发",
                    new Dictionary<string, object>
                    {
                        {"class","send"} ,{"mask","true"},{"target","dialog"},{"width","400"},{"height","320"},{"warn","请选择一条信息"}
                    })
            </li>
        </ul>
    </div>
    <table id="DailyCheckTable" class="table" width="100%" layouth="122">
        <thead>
            <tr align="center">
                <th width="30">序号
                </th>
                @* <th width="150">检查单位</th>*@
                <th width="150">被检单位
                </th>
                <th width="100">被检单位标段
                </th>
                <th width="100">检查时间
                </th>
                <th width="100">是否存在问题
                </th>
                <th>问题简写
                </th>
                <th width="100">整改期限
                </th>
                <th width="130">整改状态
                </th>
            </tr>
        </thead>
        <tbody>
            @{ int num = (ViewBag.pageNum - 1) * ViewBag.numPerPage;}
            @foreach (var info in Model.TheDailycheckList)
            {
                num += 1;
                string color = "";
                string state = "";
                if (info.Dc_IsPro)
                {
                    switch (info.Dc_State)
                    {
                        case 0:
                            state = "草稿";
                            color = "color: #000";
                            break;
                        case 1:
                            state = "整改中";
                            color = "color: #ffd800";
                            break;
                        case 2:
                            if (info.Dc_TypeCode == "2" || info.Dc_TypeCode == "3")
                            {
                                state = "整改中";
                                color = "color: #ffd800";
                                break;
                            }
                            else
                            {
                                state = "驻地办审核";
                                color = "color: blue";
                                break;
                            }
                        case 3:
                            if (info.Dc_TypeCode == "4")
                            {
                                state = "整改中";
                                color = "color: #ffd800";
                                break;
                            }
                            else
                            {
                                state = "总监办审核";
                                color = "color: blue";
                                break;
                            }
                        case 4:
                            state = "安监部审核";
                            color = "color: blue";
                            break;
                        case 5:
                            state = "整改完成";
                            color = "color: #1eb138";
                            break;
                        default:
                            break;
                    }
                    if (info.Dc_CorrectTime != null)
                    {
                        if (DateTime.Now > info.Dc_CorrectTime)
                        {
                            state += "(整改超时)";
                            color = "color: red;";
                        }
                    }
                }
                else
                {
                    state = "";
                    color = "color: #808080";
                }
                <tr style="@color" target="tr_id" rel="@info.Dc_ID" align="center" data-sole="ScmDailyCheckList" data-state="@info.Dc_State" data-ispro="@info.Dc_IsPro">
                    <td>@num
                    </td>
                    @*<td>@info.Dc_CheckDepName</td>*@
                    <td>
                        <a style="@color" href="@Url.Action("DailyCheckDetail", "ScmDailyCheck", new { id = info.Dc_ID })" mask="true" rel="ctgl_jc_edit" target="dialog" width="820" height="230">@info.Dc_BeCheckedDepName</a>
                    </td>
                    <td>@info.Dc_BeCheckedSection
                    </td>
                    <td>@info.Dc_CheckTime.ToString("yyyy-MM-dd")
                    </td>
                    <td>@(info.Dc_IsPro == true ? "是" : "否")
                    </td>
                    <td>@info.Dc_BriefProblem
                    </td>
                    <td>@(info.Dc_CorrectTime == null ? "" : Convert.ToDateTime(info.Dc_CorrectTime).ToString("yyyy-MM-dd"))
                    </td>
                    <td>@state
                    </td>
                </tr>
            }
        </tbody>
    </table>
    <div class="panelBar" style="border-bottom: none;">
        <div class="pages" style="float: right">
            <span>显示</span>
            <select class="comsplitpage" name="numPerPage" onchange="navTabPageBreak({numPerPage:this.value})">
                <option value="10" @(ViewBag.numPerPage == 10 ? "selected='selected'" : "")>10</option>
                <option value="20" @(ViewBag.numPerPage == 20 ? "selected='selected'" : "")>20</option>
                <option value="50" @(ViewBag.numPerPage == 50 ? "selected='selected'" : "")>50</option>
            </select>
            <span>条，共@(ViewBag.pagenumshown)页,@(ViewBag.totalcount)条</span>
        </div>
        <div class="pagination" style="margin:0px;float:left; margin-left:35%" targettype="navTab" totalcount="@(ViewBag.totalcount)" numperpage="@(ViewBag.numPerPage)" pagenumshown="10" currentpage="@(ViewBag.pageNum)">
        </div>
    </div>
</div>
<script>
    $.jTableTool.clickRowAction(function ($row) {
        if ($row) {
            var sole = $row.data("sole");
            if (sole != "ScmDailyCheckList")
                return;
            else {
                var state = $row.data("state");
                var ispro = $row.data("ispro");
                //存在问题的审批状态才有用：0=草稿，1=整改中，2=反馈给驻地办，3=反馈给总监办，4=反馈给安监部，5=整改完成
                if (ispro == "True") {
                    if (state != 0) {
                        //已经下发了
                        $("#listDeleteId").hide();
                        $("#listEditId").hide();
                        if (state == 5)
                            $("#listExtendCorrectTermId").hide();
                        else
                            $("#listExtendCorrectTermId").show();
                        $("#listApprovalId").hide();
                    } else {
                        $("#listDeleteId").show();
                        $("#listEditId").show();
                        $("#listExtendCorrectTermId").hide();
                        $("#listApprovalId").show();
                    }
                }
                if (ispro == "False") {
                    $("#listDeleteId").show();
                    $("#listEditId").show();
                    $("#listExtendCorrectTermId").hide();
                    $("#listApprovalId").hide();
                }
            }
        }
    });
</script>
